package cn.edu.lingnan.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.lingnan.dao.ScoreDAO;
import cn.edu.lingnan.dto.Score;

public class InsertServlet extends HttpServlet {
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String sid=req.getParameter("sid");
		String oid=req.getParameter("oid");
		int oscore=Integer.parseInt( req.getParameter("oscore"));
		Score s=new Score();
		s.setsId(sid);
		s.setoId(oid);
		s.setoScore(oscore);
		ScoreDAO sd=new ScoreDAO();
		int flag=sd.insertInfoToScore(s);
		System.out.println(flag);
		if(flag==1)
			resp.sendRedirect(req.getContextPath()+"/admin/admin.html");
		else
			resp.sendRedirect(req.getContextPath()+"/error.html");
	}
}
